<html>
<head><title>webclip - options</title></head>
<script type="text/javascript">

// TODO: move constants to a common file.

// Saves options to localStorage.
function save_options() {
  var name = document.getElementById("documentName").value;
  if (name != null && name != '') {
    localStorage["documentName"] = name; 
  }

  // Update status to let user know options were saved.
  var status = document.getElementById("status");
  status.innerHTML = "Options Saved.";
  setTimeout(function() {
    status.innerHTML = "";
  }, 750);
}

// Restores select box state to saved value from localStorage.
function restore_options() {
  var name = localStorage["documentName"];
  if (!name) {
    return;
  }
  document.getElementById("documentName").value = name;
}

</script>

<body onload="restore_options()">

Document name:
<input id="documentName" />
<br>
<div id="status" />
<br>
<button onclick="save_options()">Save</button>
</body>
</html>
